#include<filesystem>

#include<fstream>
#include<iostream>
#include<cstring>


static std::string UrlEncode(const std::string url,bool convert_space_to_plus)
    {
        std::string res;

        //isalnums检测字符是否是数字或字母
        for(auto &c:url)
        {
            if(c=='.'||c=='-'||c=='_'||c=='~'||isalnum(c))
            {
                res+=c;
                continue;
            }

            if(c==' '&&convert_space_to_plus==true)
            {
                res+='+';
                continue;
            }

            char temp[4]={0};
            snprintf(temp,4,"%%%02X",c);
            res+=temp;
        }
        return res;
    }


int main()
{
    std::string str="c++";
    std::cout<<UrlEncode(str,false)<<std::endl;
    return 0;
}